<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
    <link rel="stylesheet" href="/Public/Admin/css/style.css"/>
    <style>
        .layui-form .layui-form-item label.layui-form-label{width:150px}
        .layui-input, .layui-textarea{width:90%}
        #upload{background:url(/Public/Admin/images/file.png) no-repeat left center;padding-left:20px;padding-bottom:20px;display: inline-block;height: 38px;line-height: 38px;}
        .layui-form-item .title{font-size: 14px;font-weight: bold;border-bottom: 2px solid #2299ee;display: block;padding-bottom: 6px}
    </style>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Flow/flowStep',array('flow_id'=>$flow_id))}">返回</a>
                    </div>
                </blockquote>

                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="inputArea">
                        <div class="layui-form-item">
                            <span class="title" style="border:0">{$flow_id|getFlowName}->{$info.prcs_name} - 生成该本步骤条件 <img class="pointer arrow" src="/Public/Admin/images/down.png" /></span>
                        </div>
                        <div class="layui-form-item">
                            <div class="con-input" style="">
                                <div class="con-l">
                                    <span class="con-name">字段：</span>
                                    <select name="" class="layui-select field">
                                        <foreach name="titles" item="title">
                                            <option value="{$title}">{$title}</option>
                                        </foreach>
                                        <option value="[主办人会签意见]">[主办人会签意见]</option>
                                        <option value="[经办人会签意见]">[经办人会签意见]</option>
                                        <option value="[当前流程设计步骤号]">[当前流程设计步骤号]</option>
                                        <option value="[当前主办人姓名]">[当前主办人姓名]</option>
                                        <option value="[当前主办人角色]">[当前主办人角色]</option>
                                        <option value="[当前主办人辅助角色]">[当前主办人辅助角色]</option>
                                        <option value="[当前主办人部门]">[当前主办人部门]</option>
                                        <option value="[流程发起人角色]">[流程发起人角色]</option>
                                    </select>
                                </div>
                                <div class="con-c">
                                    <span class="con-name">条件：</span>
                                    <select name="" class="layui-select sign">
                                        <option value="=">等于</option>
                                        <option value="<>">不等于</option>
                                        <option value=">">大于</option>
                                        <option value="<">小于</option>
                                        <option value=">=">大于等于</option>
                                        <option value="<=">小于等于</option>
                                        <option value="include">包含</option>
                                        <option value="exclude">不包含</option>
                                    </select>
                                </div>
                                <div class="con-r">
                                    <span class="con-name">文本值：</span>
                                    <input type="text" class="layui-select value" name="" value="" />
                                </div>
                                <p class="clear"></p>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="con-input">
                                <a href="#" class="layui-btn addPrcsIn">添加转入条件</a>
                                <a href="#" class="layui-btn addPrcsOut">添加转出条件</a>
                            </div>
                        </div>
                    </div>

                    <div class="tableArea">
                        <div class="layui-form-item">
                            <span class="title" style="border:0">{$flow_id|getFlowName}->{$info.prcs_name} - 转入条件列表 <img class="pointer arrow" src="/Public/Admin/images/down.png" /></span>
                        </div>
                        <div class="layui-form-item">
                            <p class="con-red">说明:合理设定转入条件，可形成流程的条件分支，但数据满足转入条件，才可转入本步骤</p>
                        </div>
                        <div class="layui-form-item">
                            <table class="layui-table prcsIn">
                                <tr>
                                    <th width="10%">编号</th>
                                    <th>条件描述</th>
                                    <th width="30%">操作</th>
                                </tr>
                                <foreach name="info.prcs_in" key="key" item="in">
                                    <tr>
                                        <td>{$key+1}</td>
                                        <td class="prcsStr">
                                            <span class="">{$in|filterField}</span>
                                            <input type="text" class="layui-input conInput hide" name="prcs_in[]" value="{$in}" />
                                        </td>
                                        <td>
                                            <a class="editPrcsIn pointer">编辑</a>
                                            <a class="pointer delPrcsCon">删除</a>
                                        </td>
                                    </tr>
                                </foreach>
                            </table>
                            <input type="hidden" id="flowConditionUrl" value="{:U('saveCondition',array('flow_id'=>$flow_id,'prcs_id'=>$prcs_id))}">
                        </div>
                        <div class="layui-form-item">
                            <div class="con-input"><span class="con-tit">转入条件公式(条件与逻辑运算符之间需空格，如[1] AND [2])</span></div>
                            <div class="con-input">
                                <input type="text" name="prcs_in_set" class="layui-input" value="{$info.prcs_in_set}">
                                <span class="errMsg"></span>
                            </div>
                        </div>
                    </div>

                    <div class="tableArea">
                        <div class="layui-form-item">
                            <span class="title" style="border:0">{$flow_id|getFlowName}->{$info.prcs_name} - 转出条件列表 <img class="pointer arrow" src="/Public/Admin/images/down.png" /></span>
                        </div>
                        <div class="layui-form-item">
                            <table class="layui-table prcsOut">
                                <tr>
                                    <th width="10%">编号</th>
                                    <th>条件描述</th>
                                    <th width="30%">操作</th>
                                </tr>
                                <foreach name="info.prcs_out" key="key" item="out">
                                    <tr>
                                        <td>{$key+1}</td>
                                        <td class="prcsStr">
                                            <span>{$out|filterField}</span>
                                            <input type="text" class="layui-input conInput hide" name="prcs_out[]" value="{$out}" />
                                        </td>
                                        <td>
                                            <a class="editPrcsIn pointer">编辑</a>
                                            <a class="pointer delPrcsCon">删除</a>
                                        </td>
                                    </tr>
                                </foreach>
                            </table>
                        </div>
                        <div class="layui-form-item">
                            <div class="con-input"><span class="con-tit">转出条件公式(条件与逻辑运算符之间需空格，如[1] AND [2])</span></div>
                            <div class="con-input">
                                <input type="text" name="prcs_out_set" class="layui-input" value="{$info.prcs_out_set}">
                                <span class="errMsg"></span>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="con-input"><span class="con-tit">不符合条件公式时，给用户的文字描述：</span></div>
                            <div class="con-input">
                                <input type="text" name="condition_desc" class="layui-input" value="{$info.condition_desc}">
                                <span class="errMsg"></span>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block button">
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('flowCondition')}" data-form="">保存</a>
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        </div>
                    </div>
                    <input type="hidden" name="flow_id" value="{$flow_id}">               
                    <input type="hidden" name="prcs_id" value="{$prcs_id|default=0}">
                </form>
                <!-- 完 -->
            </div>
        </div>
    </section>
</block>
<block name="script">

    <script type="text/javascript" src="/Public/Admin/js/flow.js"></script>
    <script type="text/javascript">
        $(initFlowCondition());

        //检查表单
        $('.ajax-post').on('click', function () {
            var flag = true;
            var inLen = $('.prcsIn tr').length;
            if(inLen > 1 && $('input[name=prcs_in_set]').val() == ''){
                flag = false;
                    var msg = '请填写转入条件公式！'
                    $('input[name=prcs_in_set]').next().text(msg);
            }else{
                $('input[name=prcs_in_set]').next().text('');
            }
            
            var outLen = $('.prcsOut tr').length;
            if(outLen > 1 && $('input[name=prcs_out_set]').val() == ''){
                flag = false;
                    var msg = '请填写转出条件公式！'
                    $('input[name=prcs_out_set]').next().text(msg);
            }else{
                $('input[name=prcs_out_set]').next().text('');
            }

            if (flag == false) {
                $(this).removeClass('btn-submit');
            } else {
                $(this).addClass('btn-submit');
            }
        })
    </script>    
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
</block>
